import { requestHos } from "@/utils/http";

//数据类型1：请求医院设置的参数类型
export interface hosSetListParamsType {
  page: number;
  limit: number;
  hosname?: string;
  hoscode?: string;
}
//数据类型2：医院列表每一项的类型
export interface hosSetListItemType {
  id: number;
  createTime: string;
  updateTime: string;
  isDeleted: number;
  param: any;
  hosname: string;
  hoscode: string;
  apiUrl: string;
  signKey: string;
  contactsName: string;
  contactsPhone: string;
  status: number;
}

//基本写法 数组写法 每一项数据类型合成整体列表
//医院列表类型
export type hosSetListType = hosSetListItemType[];

//数据类型3 医院列表的完整数据对象类型
export interface hosSeyListDataType {
  records: hosSetListType;
  total: number;
  size: number;
  current: number;
  orders: any[];
  hitCount: boolean;
  searchCount: boolean;
  pages: number;
}

//数据类型4 新增或修改医院参数类型

export interface addHospitalDetaIlType {
  id?: number;
  apiUrl: string;
  contactsName: string;
  contactsPhone: string;
  createTime: string;
  hoscode: string;
  hosname: string;
}

//函数1  请求医院设置的分页列表  ajax接口——/admin/hosp/hospitalSet/{page}/{limit}
export const reqHospitalSetList = ({
  page = 1,
  limit = 3,
  hosname = "",
  hoscode = "",
}) => {
  return requestHos.get<any, hosSeyListDataType>(
    `/admin/hosp/hospitalSet/${page}/${limit}`,
    {
      params: {
        hosname,
        hoscode,
      },
    }
  );
};

//新增医院请求
export const reqAddHospital = (data: addHospitalDetaIlType) => {
  return requestHos.post<any, null>(`/admin/hosp/hospitalSet/save`, data);
};

//修改医院请求

export const reqHosDetailById = (id: number) => {
  return requestHos.get<any, hosSetListItemType>(
    `/admin/hosp/hospitalSet/get/${id}`
  );
};

//修改医院数据请求
export const reqUpdateHospital = (data: addHospitalDetaIlType) => {
  return requestHos.put<any, null>(`/admin/hosp/hospital/update`, data);
};

// 请求函数5：根据id删除医院

export const reqDeletHosByID = (id: number) => {
  return requestHos.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`);
};

//点击删除多个医院
export const reqDeleteBatchHos = (idList: number[]) => {
  return requestHos.delete<any, null>(`/admin/hosp/hospitalSet/batchRemove`, {
    data: idList,
  });
};
